<#assign className=table.className>
<#assign classNameFirstLower=className?uncap_first>
<#assign classNameLowerCase=className?lower_case>
<#assign pkJavaType=table.idColumn.javaType>

package ${basepackage}.controller;

import com.cysyz.mylib.dao.Conds;
import com.cysyz.mylib.dao.PagingResult;
import com.cysyz.mylib.utils.xsvmaker.XsvMaker;
import com.cysyz.mylib.utils.xsvmaker.impl.XsvMakerImpl;
import com.cysyz.springmvc.permission.domain.*;
import com.cysyz.springmvc.service.BaseService;
import com.cysyz.springmvc.user.domain.SysUser;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class ${className}Service extends BaseService{


    public void addNew${className}(${className} ${classNameFirstLower}) {
        this.save(${classNameFirstLower});
    }

    public void edit${className}(${className} ${classNameFirstLower}) {
        this.merge(${className}.class, ${classNameFirstLower});
    }

    public PagingResult<${className}> get${className}List(${className} ${classNameFirstLower}, int page, int pageSize) {
        Conds conds = new Conds ("${classNameFirstLower}");
        if (${classNameFirstLower} != null) {
        <#list table.notPkColumns as column>
            <#if (column.extColumnMetaData.searchCond)!false>
                <#if column.javaType == 'java.lang.String'>
                    conds.addFilterByDefaultTableName("${column.columnAlias}", "%like%", ${classNameFirstLower}.get${column.columnName}());

                    <#elseif column.isRangeType && column.isDateTimeColumn>
                        conds.addFilterByDefaultTableName("${column.columnAlias}", ">=", ${classNameFirstLower}.get${column.columnName}Begin());
                        conds.addFilterByDefaultTableName("${column.columnAlias}", "<=", ${classNameFirstLower}.get${column.columnName}End());

                    <#elseif column.isRangeType>
                        conds.addFilterByDefaultTableName("${column.columnAlias}", ">=", ${classNameFirstLower}.get${column.columnName}Min());
                        conds.addFilterByDefaultTableName("${column.columnAlias}", "<=", ${classNameFirstLower}.get${column.columnName}Max());
                    <#else>
                        conds.addFilterByDefaultTableName("${column.columnAlias}", "=", ${classNameFirstLower}.get${column.columnName}());
                </#if>
            </#if>
        </#list>
        }
        return this.listPaging(${className}.class, conds, page, pageSize);
    }
}
